import { request } from './request'

export function getDetail(iid) {
  return request({
    url: 'detail',
    params: {
      iid
    }
  })
}
// 商品封装
export class Goods {
  constructor(itemInfo, columns, services) {
    this.title = itemInfo.title //标题
    this.desc = itemInfo.desc // 折扣
    this.newPrice = itemInfo.price // 最新价格
    this.oldPrice = itemInfo.oldPrice // 旧的价格
    this.discount = itemInfo.discountDesc // 折后价
    this.columns = columns // 收藏
    this.services = services // 运输信息
    this.realPrice = itemInfo.lowNowPrice
  }
}


// 推荐信息封装
export class Shop {
  constructor(shopInfo) {
    this.logo = shopInfo.shopLogo // 头像
    this.name = shopInfo.name // 店铺名
    this.fans = shopInfo.cFans
    this.sells = shopInfo.cSells
    this.score = shopInfo.score
    this.goodsCount = shopInfo.cGoods
  }
}

// 店铺信息封装
export class GoodsParam {
  constructor(info, rule) {
    // 注: images可能没有值(某些商品有值, 某些没有值)
    this.image = info.images ? info.images[0] : ''
    this.infos = info.set
    this.sizes = rule.tables
  }
}


export function getRecommend() {
  return request({
    url: '/recommend'
  })
}
